package com.jfm.jfmc.plugin.snmp.utils;

import org.snmp4j.fluent.TargetBuilder;

/**
 * @author DYang
 * @since 2024-10-10 21:22
 *
 * SNMP V3协议加密
 */
public class EncryUtil {

    private static final String AES128 = "AES128";

    private static final String SHA1 = "SHA1";

    /**
     * 获取私有加密方式
     * @param privPasswordEncryption
     * @return
     */
    public static TargetBuilder.PrivProtocol getPrivPasswordEncryption(String privPasswordEncryption) {
        if (privPasswordEncryption == null) return TargetBuilder.PrivProtocol.des;
        else if (AES128.equals(privPasswordEncryption)) {
            return TargetBuilder.PrivProtocol.aes128;
        } else return TargetBuilder.PrivProtocol.des;
    }

    /**
     * 获取密码认证加密方式
     * @param authPasswordEncryption
     * @return
     */
    public static TargetBuilder.AuthProtocol getAuthPasswordEncryption(String authPasswordEncryption) {
        if (authPasswordEncryption == null) return TargetBuilder.AuthProtocol.md5;
        else if (SHA1.equals(authPasswordEncryption))  return TargetBuilder.AuthProtocol.sha1;
        else return TargetBuilder.AuthProtocol.md5;
    }
}
